Best Syzkaller code snippet using x86.mov8
pseudo.go
Source:pseudo.go
...323 default:324 panic("bad mode")325 }326}327func (gen *generator) mov8(reg int, v uint8) {328 switch reg {329 case regAL:330 gen.byte(0xb0)331 case regCL:332 gen.byte(0xb1)333 case regDL:334 gen.byte(0xb2)335 default:336 panic("unknown register")337 }338 gen.byte(v)339}340func (gen *generator) mov16(reg int, v uint16) {341 gen.operand16()342 switch reg {343 case regAX:344 gen.byte(0xb8)345 case regCX:346 gen.byte(0xb9)347 case regDX:348 gen.byte(0xba)349 default:350 panic("unknown register")351 }352 gen.imm16(v)353}354func (gen *generator) mov32(reg int, v uint32) {355 gen.operand32()356 switch reg {357 case regEAX:358 gen.byte(0xb8)359 case regECX:360 gen.byte(0xb9)361 case regEDX:362 gen.byte(0xba)363 default:364 panic("unknown register")365 }366 gen.imm32(v)367}368func (gen *generator) mov64(reg int, v uint64) {369 if gen.mode != iset.ModeLong64 {370 panic("bad mode")371 }372 gen.byte(0x48)373 switch reg {374 case regRAX:375 gen.byte(0xb8)376 case regRCX:377 gen.byte(0xb9)378 case regRDX:379 gen.byte(0xba)380 default:381 panic("unknown register")382 }383 gen.imm64(v)384}385// movl $v, off(%rsp).386func (gen *generator) mov32toSPaddr(v uint32, off uint8) {387 gen.addr32()388 gen.operand32()389 gen.byte(0xc7, 0x44, 0x24, off)390 gen.imm32(v)391}392func (gen *generator) xor32(reg int, v uint32) {393 gen.operand32()394 switch reg {395 case regEAX:396 gen.byte(0x35)397 default:398 panic("unknown register")399 }400 gen.imm32(v)401}402func (gen *generator) readCR(cr uint8) {403 if cr < 8 {404 // MOV %crN, %eax/%rax405 gen.byte(0x0f, 0x20, 0xc0|cr<<3)406 } else if cr < 16 {407 // MOV %crN, %eax/%rax408 gen.byte(0x44, 0x0f, 0x20, 0xc0|(cr-8)<<3)409 } else {410 panic("bad cr")411 }412}413func (gen *generator) writeCR(cr uint8) {414 if cr < 8 {415 // MOV %eax/%rax, %crN416 gen.byte(0x0f, 0x22, 0xc0|cr<<3)417 } else if cr < 16 {418 // MOV %eax/%rax, %crN419 gen.byte(0x44, 0x0f, 0x22, 0xc0|(cr-8)<<3)420 } else {421 panic("bad cr")422 }423}424func (gen *generator) readDR(dr uint8) {425 if dr >= 8 {426 panic("bad dr")427 }428 // MOV %drN, %eax/%rax429 gen.byte(0x0f, 0x21, 0xc0|dr<<3)430}431func (gen *generator) writeDR(dr uint8) {432 if dr >= 8 {433 panic("bad dr")434 }435 // MOV %eax/%rax, %drN436 gen.byte(0x0f, 0x23, 0xc0|dr<<3)437}438func (gen *generator) in8(port uint16) {439 gen.mov16(regDX, port)440 gen.byte(0xec) // in %al, %dx441}442func (gen *generator) in16(port uint16) {443 gen.mov16(regDX, port)444 gen.operand16()445 gen.byte(0xed) // in %ax, %dx446}447func (gen *generator) in32(port uint16) {448 gen.mov16(regDX, port)449 gen.operand32()450 gen.byte(0xed) // in %eax, %dx451}452func (gen *generator) in(port uint16, size int) {453 switch size {454 case 0:455 gen.in8(port)456 case 1:457 gen.in16(port)458 case 2:459 gen.in32(port)460 default:461 panic("bad size")462 }463}464func (gen *generator) out8(port uint16, v uint8) {465 gen.mov16(regDX, port)466 gen.mov8(regAL, v)467 gen.byte(0xee) // out %dx, %al468}469func (gen *generator) out16(port, v uint16) {470 gen.mov16(regDX, port)471 gen.mov16(regAX, v)472 gen.operand16()473 gen.byte(0xef) // out %dx, %ax474}475func (gen *generator) out32(port uint16, v uint32) {476 gen.mov16(regDX, port)477 gen.mov32(regEAX, v)478 gen.operand32()479 gen.byte(0xef) // out %dx, %eax480}...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!